﻿using VisualWip.Core.Interfaces;
using VisualWip.Core.SlotsProviders;

namespace VisualWip.Core.Columns
{
    public class WorkSingleColumn : WorkColumnBase
    {
        private bool _availibility;

        public WorkSingleColumn()
            : base()
        {
            Availibility = true;
        }

        public override ISlotsProvider SlotsProvider
        {
            get { return new SlotsProvider(Availibility); }
        }

        public bool Availibility
        {
            get { return _availibility; }
            set
            {
                if (value != _availibility)
                {
                    _availibility = value;
                    OnPropertyChanged(this, () => Availibility);
                }
            }
        }


        public override PersistenceTree Persist(string name)
        {
            PersistenceTree settings = base.Persist(name);
            settings.Add(() => Availibility);
            return settings;
        }

        public override void Load(PersistenceTree settings)
        {
            base.Load(settings);
            
            Availibility = settings.Get(() => Availibility,true);
        }
    }
}